package com.foreveross.ccjd;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import cn.jpush.android.api.JPushInterface;

import com.foreveross.ccjd.chart.ChartView;
import com.zxing.activity.CaptureActivity;

public class MainActivity extends Activity implements OnClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		findViewById(R.id.btn_code).setOnClickListener(this);
		findViewById(R.id.btn_login).setOnClickListener(this);
		findViewById(R.id.btn_register).setOnClickListener(this);
		findViewById(R.id.btn_push_init).setOnClickListener(this);
		findViewById(R.id.btn_push_stop).setOnClickListener(this);
		ChartView chartView = new ChartView(this, 24, 5);
		LinearLayout layout = (LinearLayout) findViewById(R.id.layout);

		layout.addView(chartView);
	}

	private static final int REQUEST_CODE = 1001;

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btn_code: {
			Intent intent = new Intent(this, CaptureActivity.class);
			startActivityForResult(intent, REQUEST_CODE);
		}
			break;
		case R.id.btn_login:
		{
			Intent intent = new Intent(this, LoginActivity.class);
			startActivityForResult(intent, REQUEST_CODE);
		}
			break;
		case R.id.btn_register:
			Intent intent = new Intent(this, RegisterActivity.class);
			startActivityForResult(intent, REQUEST_CODE);
			break;
		case R.id.btn_push_init:
			JPushInterface.init(getApplicationContext());
			if(JPushInterface.isPushStopped(getApplicationContext()))
			JPushInterface.resumePush(getApplicationContext());
			break;
		case R.id.btn_push_stop:
			JPushInterface.stopPush(getApplicationContext());
			break;
		default:
			break;
		}

	}
}
